package com.qs.service.impl;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.IdcardUtil;
import cn.hutool.log.Log;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qs.constant.EsConstant;
import com.qs.constant.LoginConstant;
import com.qs.constant.RedisConstant;
import com.qs.constant.StatusConstant;
import com.qs.es.service.EsGoodsService;
import com.qs.es.service.EsStoreService;
import com.qs.exception.ServiceException;
import com.qs.mapper.*;
import com.qs.pojo.dto.GoodsInfoDto;
import com.qs.pojo.dto.StoreDto;
import com.qs.pojo.dto.StoreFirstDto;
import com.qs.pojo.dto.StoreInfoDto;
import com.qs.pojo.entity.*;
import com.qs.pojo.es.EsStoreDto;
import com.qs.pojo.vo.PayInfoVo;
import com.qs.pojo.vo.StoreVo;
import com.qs.response.ResponseEnum;
import com.qs.service.IStoreService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.io.IOException;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;

/**
 * <p>
 * 商家表 服务实现类
 * </p>
 *
 * @author author
 * @since 2023-11-12
 */
@Service
@RequiredArgsConstructor
public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements IStoreService {

    private final UserMapper userMapper;

    private final GoodsMapper goodsMapper;

    private final RedisTemplate redisTemplate;

    private final EsStoreService esStoreService;

    private final StoreCommentMapper storeCommentMapper;

    private final CollectStoreMapper collectStoreMapper;

    private final UserGoodsLogMapper userGoodsLogMapper;

    private final PayInfoMapper payInfoMapper;

    private final OrderInfoMapper orderInfoMapper;

    @Override
    public Map<String, Object> getList(Integer pageNo, Integer pageSize, StoreVo storeVo) {
        //去除前后空白
        String trimHomeName = storeVo.getHomeName().trim();
        String trimStatus = storeVo.getStatus().trim();
        Page<Store> pageInfo = new Page<>(pageNo,pageSize);
        QueryWrapper<Store> wrapper = new QueryWrapper<>();
        /**
         * 进行模糊查询
         */
        wrapper.eq(!StringUtils.isBlank(trimHomeName),"home_name",trimHomeName);
        wrapper.eq(!StringUtils.isBlank(trimStatus),"status",trimStatus);
        //只查询审核通过的店铺
        wrapper.eq("status",StatusConstant.STATUS_STORE_PASS);
        wrapper.orderByDesc("update_time");
        Page<Store> businessPage = baseMapper.selectPage(pageInfo,wrapper);
        if(null != businessPage) {
            //进行数据转换
            List<Store> records = businessPage.getRecords();
            List<StoreDto> storeDtoList = new ArrayList<>();
            records.stream().forEach(item -> {
                User user = userMapper.selectById(item.getUserId());
                StoreDto storeDto = new StoreDto();
                BeanUtils.copyProperties(item, storeDto);
                storeDto.setKey(item.getId());
                storeDto.setName(user.getName());
                storeDto.setIdCard(user.getIdCard());
                storeDtoList.add(storeDto);
            });
            Map<String,Object> map = new HashMap<>();
            map.put("data", storeDtoList);
            map.put("total",businessPage.getTotal());
            return map;
        }
        return null;
    }

    @Override
    public StoreDto echo(Integer id) {
        if(null != id){
            Store store = baseMapper.selectById(id);
            User user = userMapper.selectById(store.getUserId());
            StoreDto storeDto = new StoreDto();
            BeanUtils.copyProperties(store, storeDto);
            storeDto.setKey(store.getId());
            storeDto.setIdCard(user.getIdCard());
            return storeDto;
        }
        return null;
    }

    @Override
    public void updateByKey(StoreDto storeDto) {
        boolean validCard = IdcardUtil.isValidCard(storeDto.getIdCard());
        /**
         * 身份证是否合法
         */
        if(!validCard) {
            throw new ServiceException(ResponseEnum.ID_CARD_ILLEGAL);
        }
        /**
         * 一个身份证号只能查出一个用户
         */
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(!StringUtils.isEmpty(storeDto.getIdCard()),"id_card",storeDto.getIdCard());
        List<User> userList = userMapper.selectList(queryWrapper);
        if(userList.size() > 1) {
            throw new ServiceException(ResponseEnum.ID_CARD_USED);
        }
        Store store = baseMapper.selectById(storeDto.getKey());
        BeanUtils.copyProperties(storeDto, store);
        //因为是商户修改了店铺信息，所以需要重新审核
        store.setStatus(StatusConstant.STATUS_STORE);
        store.setIsRead(StatusConstant.NOT_READ);
        baseMapper.updateById(store);
        //将redis中的数据清空
        redisTemplate.delete(RedisConstant.USER_STORE + store.getUserId());
    }

    @Override
    public void saveStore(Store store) {
        /**
         * 身份证是否合法
         */
        if(!IdcardUtil.isValidCard(store.getIdCard())) {
            throw new ServiceException(ResponseEnum.ID_CARD_ILLEGAL);
        }
        /**
         * 校验此身份证的人是否已注册
         */
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq(!StringUtils.isEmpty(store.getIdCard()),"id_card",store.getIdCard());
        User user = userMapper.selectOne(wrapper);
        if(null == user) {
            throw new ServiceException(ResponseEnum.DO_NOT_OPEN_STORE);
        }
        /**
         * 商户名称唯一
         */
        QueryWrapper<Store> wr = new QueryWrapper<>();
        wr.eq(!StringUtils.isEmpty(store.getIdCard()),"home_name",store.getHomeName());
        Store storeOne = baseMapper.selectOne(wr);
        if( null != storeOne){
            throw new ServiceException(ResponseEnum.HOME_NAME_EXITS);
        }
        /**
         * 一个身份证号也就是一个人只能拥有5个商铺
         */
        QueryWrapper<Store> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(!StringUtils.isEmpty(store.getIdCard()),"user_id",user.getId());
        List<Store> stores = baseMapper.selectList(queryWrapper);
        if(stores.size() >= 5){
            throw new ServiceException(ResponseEnum.NUMBER_IS_FULL);
        }
        store.setUserId(user.getId());
        if(StringUtils.isEmpty(store.getStatus())){
            //默认设置为审核中
            store.setStatus(StatusConstant.STATUS_STORE);
        }
        baseMapper.insert(store);
        //将当前用户的角色修改为商户
        if(!user.getRole().equalsIgnoreCase(LoginConstant.ROLE_BUSINESS)){
            user.setRole(LoginConstant.ROLE_BUSINESS);
            userMapper.updateById(user);
        }
        //将redis中的数据清空
        redisTemplate.delete(RedisConstant.USER_STORE + store.getUserId());
    }

    @Override
    public List<StoreDto> getFrontList(Integer userId) {
        if(null != userId){
            QueryWrapper<Store> wrapper = new QueryWrapper<>();
            wrapper.eq("user_id", userId);
            List<Store> stores = baseMapper.selectList(wrapper);
            Map<String,Object> map = new HashMap<>();
            if(!CollectionUtils.isEmpty(stores)) {
                //进行数据转换
                List<StoreDto> storeDtoList = new ArrayList<>();
                User user = userMapper.selectById(userId);
                stores.stream().forEach(item -> {
                    StoreDto storeDto = new StoreDto();
                    BeanUtils.copyProperties(item, storeDto);
                    storeDto.setKey(item.getId());
                    storeDto.setName(user.getName());
                    storeDto.setIdCard(user.getIdCard());
                    storeDtoList.add(storeDto);
                });
                return storeDtoList;
            }
            return null;
        }
        return null;
    }

    @Override
    public Map<String, Object> getStoresInfo(Integer pageNo, Integer pageSize, Integer storeId) {
        Page<Goods> pageInfo = new Page<>(pageNo, pageSize);
        QueryWrapper<Goods> wrapper = new QueryWrapper<>();
        wrapper.eq("store_id", storeId);
        wrapper.orderByDesc("update_time");
        //获取商铺对应的商铺分页数据
        Page<Goods> goodsPage = goodsMapper.selectPage(pageInfo, wrapper);
        //获取商铺的基本信息
        Store store = baseMapper.selectById(storeId);
        if(null != goodsPage) {
            List<Goods> goodsList = goodsPage.getRecords();
            List<GoodsInfoDto> list = new ArrayList<>(goodsList.size());
            if(!CollectionUtils.isEmpty(goodsList)) {
                goodsList.stream().forEach(goods -> {
                    GoodsInfoDto goodsInfoDto = new GoodsInfoDto();
                    BeanUtils.copyProperties(goods, goodsInfoDto);
                    list.add(goodsInfoDto);
                });
                StoreInfoDto storeInfoDto = this.getStoreInfoDto(store);
                Map<String,Object> map = new HashMap<>();
                map.put("data",list);
                map.put("total",goodsPage.getTotal());
                map.put("info",storeInfoDto);
                return map;
            }
            StoreInfoDto storeInfoDto = this.getStoreInfoDto(store);
            Map<String,Object> map = new HashMap<>();
            map.put("data",null);
            map.put("total",0);
            map.put("info",storeInfoDto);
        }
        StoreInfoDto storeInfoDto = this.getStoreInfoDto(store);
        Map<String,Object> map = new HashMap<>();
        map.put("data",null);
        map.put("total",0);
        map.put("info",storeInfoDto);
        return map;
    }

    @Override
    public Map<String, Object> getStoreCheckList(Integer pageNo, Integer pageSize, StoreVo storeVo) {
        //去除前后空白
        String trimHomeName = storeVo.getHomeName().trim();
        String trimStatus = storeVo.getStatus().trim();
        Page<Store> pageInfo = new Page<>(pageNo,pageSize);
        QueryWrapper<Store> wrapper = new QueryWrapper<>();
        /**
         * 进行模糊查询
         */
        wrapper.eq(!StringUtils.isBlank(trimHomeName),"home_name",trimHomeName);
        wrapper.eq(!StringUtils.isBlank(trimStatus),"status",trimStatus);
        //只查询审核中的店铺
        wrapper.eq("status",StatusConstant.STATUS_STORE);
        wrapper.orderByDesc("update_time");
        Page<Store> businessPage = baseMapper.selectPage(pageInfo,wrapper);
        if(null != businessPage) {
            //进行数据转换
            List<Store> records = businessPage.getRecords();
            List<StoreDto> storeDtoList = new ArrayList<>();
            records.stream().forEach(item -> {
                User user = userMapper.selectById(item.getUserId());
                StoreDto storeDto = new StoreDto();
                BeanUtils.copyProperties(item, storeDto);
                storeDto.setKey(item.getId());
                storeDto.setName(user.getName());
                storeDto.setIdCard(user.getIdCard());
                storeDtoList.add(storeDto);
            });
            Map<String,Object> map = new HashMap<>();
            map.put("data", storeDtoList);
            map.put("total",businessPage.getTotal());
            return map;
        }
        return null;
    }

    @Override
    public Long getStoreCounts() {
        QueryWrapper<Store> wrapper = new QueryWrapper<>();
        wrapper.eq("status",StatusConstant.STATUS_STORE);
        Long count = baseMapper.selectCount(wrapper);
        return count;
    }

    @Override
    public Map<String,Object> getStoreIsReadCounts(Integer userId) {
        QueryWrapper<Store> wrapper = new QueryWrapper<>();
        //查询通过未读通知
        wrapper.eq("status",StatusConstant.STATUS_STORE_PASS)
                .and(item -> item.eq("is_read",StatusConstant.NOT_READ));
        Long passCounts = baseMapper.selectCount(wrapper);
        //查询未通过未读通知
        QueryWrapper<Store> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("status",StatusConstant.STATUS_STORE_NOT_PASS)
                .and(item -> item.eq("is_read",StatusConstant.NOT_READ));
        Long notPassCounts = baseMapper.selectCount(queryWrapper);
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("passCounts", passCounts);
        map.put("notPassCounts", notPassCounts);
        return map;
    }

    @Override
    public void allRead(Integer userId) {
        QueryWrapper<Store> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",userId);
        wrapper.eq("is_read",StatusConstant.NOT_READ);
        List<Store> stores = baseMapper.selectList(wrapper);
        List<Store> storeFilter = stores.stream().filter(store -> store.getStatus().equalsIgnoreCase(StatusConstant.STATUS_STORE_PASS)
                ||
                store.getStatus().equalsIgnoreCase(StatusConstant.STATUS_STORE_NOT_PASS)).collect(Collectors.toList());
        if(!CollectionUtils.isEmpty(storeFilter)){
            storeFilter.stream().forEach(item -> {
                item.setIsRead(StatusConstant.HAVE_READ);
                baseMapper.updateById(item);
            });
        }
    }

    @Override
    public void delete(List<Integer> ids,Integer userId) {
        baseMapper.deleteBatchIds(ids);
        redisTemplate.delete(RedisConstant.USER_STORE + userId);
        try {
            esStoreService.deleteDocument(ids, EsConstant.INDEX_NAME_STORE);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public Map<String, Object> searchStoreFrontList(Integer pageNo, Integer pageSize, List<Integer> ids, String msg) {
        Map<String, Object> map = null;
        try {
            map = esStoreService.searchStoreFrontList(pageNo, pageSize, ids,msg);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return map;
    }

    @Override
    public void checkStorePass(StoreDto storeDto) {
        boolean validCard = IdcardUtil.isValidCard(storeDto.getIdCard());
        /**
         * 身份证是否合法
         */
        if(!validCard) {
            throw new ServiceException(ResponseEnum.ID_CARD_ILLEGAL);
        }
        /**
         * 一个身份证号只能查出一个用户
         */
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(!StringUtils.isEmpty(storeDto.getIdCard()),"id_card",storeDto.getIdCard());
        List<User> userList = userMapper.selectList(queryWrapper);
        if(userList.size() > 1) {
            throw new ServiceException(ResponseEnum.ID_CARD_USED);
        }
        Store store = baseMapper.selectById(storeDto.getKey());
        BeanUtils.copyProperties(storeDto, store);
        baseMapper.updateById(store);
        //将redis中的数据清空
        redisTemplate.delete(RedisConstant.USER_STORE + store.getUserId());
        //如果店铺已通过则添加到es中
        if(store.getStatus().equalsIgnoreCase(StatusConstant.STATUS_STORE_PASS)){
            EsStoreDto esStoreDto = new EsStoreDto();
            esStoreDto.setKey(store.getId());
            esStoreDto.setStore(store.getHomeName());
            esStoreDto.setStoreImage(store.getImage());
            try {
                esStoreService.addDocument(esStoreDto);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }

    @Override
    public List<GoodsInfoDto> searchRecommendGoods(Integer storeId) {
        Page<Goods> pageInfo = new Page<>(1, 3);
        QueryWrapper<Goods> wrapper = new QueryWrapper<>();
        wrapper.eq("store_id", storeId);
        wrapper.orderByDesc("sale");
        //获取商铺对应的商铺分页数据
        Page<Goods> goodsPage = goodsMapper.selectPage(pageInfo, wrapper);
        if(null != goodsPage) {
            List<Goods> goodsList = goodsPage.getRecords();
            List<GoodsInfoDto> list = new ArrayList<>();
            if(!CollectionUtils.isEmpty(goodsList)) {
                goodsList.stream().forEach(goods -> {
                    GoodsInfoDto goodsInfoDto = new GoodsInfoDto();
                    BeanUtils.copyProperties(goods, goodsInfoDto);
                    list.add(goodsInfoDto);
                });
                if(!CollectionUtils.isEmpty(list)) {
                    return list;
                }
                return null;
            }
            return null;
        }
        return null;
    }

    @Override
    public Map<String, Object> findStoreNum() {
        //获取审核通过的店铺总数
        QueryWrapper<Store> wrapper = new QueryWrapper<>();
        wrapper.eq("status",StatusConstant.STATUS_STORE_PASS);
        Long count = baseMapper.selectCount(wrapper);
        //获取审核通过的昨日新增店铺总数
        Long yesterdayNum = baseMapper.findStoreYesterday();
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("count", count);
        map.put("yesterday",yesterdayNum);
        return map;
    }

    @Override
    public Map<String, Object> findGoodsTotal(Integer userId) {
        List<Integer> storeIds = this.getStoreIdCommon(userId);
        if(!CollectionUtils.isEmpty(storeIds)){
            //获取商户的总的商品订单
            Long counts = userGoodsLogMapper.findOrderCount(storeIds);
            //获取昨天的商品订单
            Long countsYesterday = userGoodsLogMapper.findOrderCountYesterday(storeIds);
            Map<String, Object> map = new HashMap<>();
            map.put("total", counts);
            map.put("yesterday", countsYesterday);
            return map;
        }
        return null;
    }

    public List<Integer> getStoreIdCommon(Integer userId){
        QueryWrapper<Store> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id", userId);
        List<Store> stores = baseMapper.selectList(wrapper);
        if(!CollectionUtils.isEmpty(stores)){
            List<Integer> storeIds = stores.stream().map(item -> item.getId()).collect(Collectors.toList());
            return storeIds;
        }
        return null;
    }

    @Override
    public Map<String, Object> findTotalPrice(Integer userId) {
        List<Integer> storeIds = this.getStoreIdCommon(userId);
        if(!CollectionUtils.isEmpty(storeIds)){
            //获取商铺对应的总订单号
            List<String> orderIds = userGoodsLogMapper.findOrderIds(storeIds);
            Float total = 0.0f;
            Float yesterday = 0.0f;
            if(!CollectionUtils.isEmpty(orderIds)){
                //获取商铺对应的总流水
                total = payInfoMapper.findTotalPrice(orderIds);
            }
            //获取商铺对应的订单号（昨天）
            List<String> orderIdsYesterday = userGoodsLogMapper.findOrderIdsYesterday(storeIds);
            //获取商铺对应的流水（昨天）
            if(!CollectionUtils.isEmpty(orderIdsYesterday)){
                yesterday = payInfoMapper.findTotalPriceYesterday(orderIdsYesterday);
            }
            Map<String, Object> map = new HashMap<>();
            map.put("total", total);
            map.put("yesterday", yesterday);
            return map;
        }
        return null;
    }

    @Override
    public Map<String, Object> findPineLineToal(Integer userId) {
        List<Integer> storeIds = this.getStoreIdCommon(userId);
        if(!CollectionUtils.isEmpty(storeIds)){
            //获取商铺的总销量
            Long total = goodsMapper.findPineLineTotal(storeIds);
            //获取商铺昨天的销量
            Long yesterday = goodsMapper.findPineLineTotalYesterday(storeIds);
            Map<String, Object> map = new HashMap<>();
            map.put("total", total);
            map.put("yesterday", yesterday);
            return map;
        }
        return null;
    }

    @Override
    public List<Float> findBusinessWeekdayData(Integer userId) {
        List<Integer> storeIds = this.getStoreIdCommon(userId);
        if(!CollectionUtils.isEmpty(storeIds)){
            //获取一周内的订单号
            List<String> orderIds = userGoodsLogMapper.findOrderWithWeekday(storeIds);
            //将每周按天分组获取每天的流水
            if(!CollectionUtils.isEmpty(orderIds)){
                List<PayInfoVo> result = orderInfoMapper.findBusinessWeekdayData(orderIds);
                List<Float> list = new ArrayList<>(Arrays.asList(0.0f, 0.0f, 0.0f, 0.0f,0.0f, 0.0f, 0.0f));
                if (!CollectionUtils.isEmpty(result)) {
                    for (PayInfoVo vo : result){
                        switch (vo.getDay()) {
                            case 1:
                                //星期天
                                list.add(6,vo.getPrice());
                                break;
                            case 2:
                                //星期一
                                list.add(0,vo.getPrice());
                                break;
                            case 3:
                                //星期二
                                list.add(1,vo.getPrice());
                                break;
                            case 4:
                                //星期三
                                list.add(2,vo.getPrice());
                                break;
                            case 5:
                                //星期四
                                list.add(3,vo.getPrice());
                                break;
                            case 6:
                                //星期五
                                list.add(4,vo.getPrice());
                                break;
                            case 7:
                                //星期六
                                list.add(5,vo.getPrice());
                                break;
                            default:
                                break;
                        }
                    }
                    return list;
                }
            }
        }
        return null;
    }

    @Override
    public Map<String, Object> getPerimeterList(Integer pageNo, Integer pageSize) {
        Page<Store> pageInfo = new Page<>(pageNo, pageSize);
        QueryWrapper<Store> wrapper = new QueryWrapper<>();
        wrapper.eq("status",StatusConstant.STATUS_STORE_PASS);
        Page<Store> storePage = baseMapper.selectPage(pageInfo, wrapper);
        if (storePage.getRecords() != null && storePage.getRecords().size() > 0) {
            List<Store> storeList = storePage.getRecords();
            if(!CollectionUtils.isEmpty(storeList)){
                List<StoreFirstDto> list = new ArrayList<>();
                storeList.stream().forEach(store -> {
                    User user = userMapper.selectById(store.getUserId());

                    QueryWrapper<StoreComment> storeCommentWrapper = new QueryWrapper<>();
                    storeCommentWrapper.eq("store_id",store.getId());
                    Long commentNum = storeCommentMapper.selectCount(storeCommentWrapper);

                    QueryWrapper<CollectStore> collectStoreWrapper = new QueryWrapper<>();
                    collectStoreWrapper.eq("store_id",store.getId());
                    Long collectNum = collectStoreMapper.selectCount(collectStoreWrapper);

                    StoreFirstDto storeFirstDto = new StoreFirstDto();
                    storeFirstDto.setKey(store.getId());
                    storeFirstDto.setImage(store.getImage());
                    storeFirstDto.setHomeName(store.getHomeName());
                    storeFirstDto.setRemark(store.getRemark());
                    storeFirstDto.setAvatar(user.getAvatar());
                    storeFirstDto.setCommentNum(commentNum);
                    storeFirstDto.setCollectNum(collectNum);

                    list.add(storeFirstDto);
                });
                Map<String, Object> map = new HashMap<String, Object>();
                map.put("total", storePage.getTotal());
                map.put("data", list);
                return map;
            }
        }
        return null;
    }

    private StoreInfoDto getStoreInfoDto(Store store){
        QueryWrapper<StoreComment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("store_id",store.getId());
        List<StoreComment> storeComments = storeCommentMapper.selectList(queryWrapper);
        int commentCount = storeComments.size();
        /**
         * 店铺评分算法：
         * 查询该店铺的所有评分总分 / 所有评分次数
         */
        float score = 0f;
        if(!CollectionUtils.isEmpty(storeComments)){
            float sumScore = 0f;
            for (StoreComment storeComment : storeComments) {
                sumScore += storeComment.getScore();
            }
            score = sumScore / commentCount;
        }

        QueryWrapper<CollectStore> wrapper = new QueryWrapper<>();
        wrapper.eq("store_id",store.getId());
        Long CollectCount = collectStoreMapper.selectCount(wrapper);

        StoreInfoDto storeInfoDto = new StoreInfoDto();
        storeInfoDto.setId(store.getId());
        storeInfoDto.setHomeName(store.getHomeName());
        storeInfoDto.setImage(store.getImage());
        storeInfoDto.setAddress(store.getAddress());
        String createTime = LocalDateTimeUtil.format(LocalDateTimeUtil.parse(store.getCreateTime().toString()), DatePattern.NORM_DATE_PATTERN);
        storeInfoDto.setCreateTime(createTime);
        Long between = LocalDateTimeUtil.between(store.getCreateTime(), LocalDateTime.now(), ChronoUnit.DAYS);
        storeInfoDto.setLongTime(between.toString());
        storeInfoDto.setComment(commentCount);
        storeInfoDto.setCollectNum(CollectCount.intValue());
        storeInfoDto.setScore(score);
        return storeInfoDto;
    }
}
